﻿using System;
using System.ComponentModel;

namespace RiskMan.DataClass.Models.Gilevskiy
{
    public class CandleItem : INotifyPropertyChanged
    {
        #region private

        private DateTime _tradeDateTime;
        private double _high;
        private double _low;
        private double _open;
        private double _close;
        private int _volume;

        #endregion

        #region public


        /// <summary>
        /// дата и вермя сформированной свечи по данному таймфрейму
        /// </summary>
        public DateTime TradeDateTime
        {
            get { return _tradeDateTime; }
            set
            {
                if (_tradeDateTime != value)
                {
                    _tradeDateTime = value;
                    RaisePropertyChanged("TradeDateTime");
                }
            }
        }

        /// <summary>
        /// High свечи по выбранному таймфрейму
        /// </summary>
        public double High
        {
            get { return _high; }
            set
            {
                if (_high != value)
                {
                    _high = value;
                    RaisePropertyChanged("High");
                }
            }
        }

        /// <summary>
        /// Low свечи по выбранному таймфрейму
        /// </summary>
        public double Low
        {
            get { return _low; }
            set
            {
                if (_low != value)
                {
                    _low = value;
                    RaisePropertyChanged("Low");
                }
            }
        }

        /// <summary>
        /// Open свечи по выбранному таймфрейму
        /// </summary>
        public double Open
        {
            get { return _open; }
            set
            {
                if (_open != value)
                {
                    _open = value;
                    RaisePropertyChanged("Open");
                }
            }
        }

        /// <summary>
        /// Close свечи по выбранному таймфрейму
        /// </summary>
        public double Close
        {
            get { return _close; }
            set
            {
                if (_close != value)
                {
                    _close = value;
                    RaisePropertyChanged("Close");
                }
            }
        }

        /// <summary>
        /// Объем свечи по выбранному таймфрейму
        /// </summary>
        public int Volume
        {
            get { return _volume; }
            set
            {
                if (_volume != value)
                {
                    _volume = value;
                    RaisePropertyChanged("Volume");
                }
            }
        }
        #endregion

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
